{% load live_engine %}
{% load news %}
{% load urls %}
{% load users %}
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>{% block head_title %}{{ LIVE_ENGINE_DEFAULT_TITLE }}{% endblock %}</title>
        <meta name="description" content="{% block head_description %}{{ LIVE_ENGINE_DEFAULT_META_DESCRIPTION }}{% endblock %}" />
        <meta name="keywords" content="{% block head_keywords %}{{ LIVE_ENGINE_DEFAULT_META_KEYWORDS }}{% endblock %}" />
        <script type="text/javascript" src="http://userapi.com/js/api/openapi.js?34"></script>
        <script type="text/javascript">
            VK.init({apiId: 2360468, onlyWidgets: true});
        </script>
        <script type="text/javascript" src="{{ STATIC_URL }}scripts/jquery.min.js"></script>
        <script type="text/javascript" src="{{ STATIC_URL }}scripts/highslide/highslide.js"></script>
        <script type="text/javascript" src="{{ STATIC_URL }}scripts/core.js"></script>
        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}scripts/highslide/highslide.css" />
        <link rel="stylesheet" href="{{ STATIC_URL }}styles/vkontakte.css?v=3" type="text/css" />
        <script src="http://vkontakte.ru/js/api/xd_connection.js?2" type="text/javascript"></script>
        <script type="text/javascript">
            params = document.location.href.split('&');
            for(var key in params){
              var param = params[key];
              param = param.split('=');
              if(param[0] == 'hash'){
                if(param[1].length > 0){
                  var url = param[1].replace('%2F','/');
                  document.location = url;
                }
              }
            }

            function resizeIframeWindow(){
                VK.callMethod('resizeWindow', '827', $('body').height());
            }

            $(document).ready(function(){
                setInterval('resizeIframeWindow()', 500);
            });
        </script>
        <!-- ui -->
        <script type="text/javascript" src="{{ STATIC_URL }}scripts/jquery-ui.min.js"></script>
        <link rel="stylesheet" href="{{ STATIC_URL }}styles/ui.css" type="text/css" />
    </head>
    <body>
        <div class="document-wrapper">
            <div id="header">
                <div class="block">
                    <div class="column-logo">
                        <a href="{% url apps.news.views.base.main %}">
                            <img src="{{ STATIC_URL }}images/logo.png" alt="Развлекательный портал Хохот!" />
                        </a>
                    </div>
                    <!--noindex-->
                    <div class="column-search">

                        {% if user.is_authenticated %}
                            <h3 style="font-size: 14px; color: #999;">Привет, <span class="green">{{ user.get_profile.get_user_name }}</span></h3>
                            <img src="{{ user.get_profile.get_avatar }}" class="user-panel-avatar" width="36" height="36" />
                            <a href="{% url users.edit %}" title="Редактирование профиля">Редактирование профиля</a><br/>
                            <a href="/rules.html" title="Правила сайта">Правила сайта</a><br/>
                        {% endif %}
                    <p>&nbsp;</p>
                        <form method="post" action="{% url apps.news.views.search.search %}">
                            <div class="header-search-form">
                                {% csrf_token %}
                                <input name="q" type="text" class="input plus-block">
                                <input type="submit" value="Искать" class="button submit plus-block">
                            </div>
                        </form>
                    </div>
                    <!--/noindex-->
                </div>
                {% main_menu %}
            </div>
            <div id="content">
                <div class="column-left">

<!-- MComposite Start -->
<div id="MarketGidComposite25860"><a href="http://marketgid.com" target="_blank">Загрузка...</a></div>
<!-- MComposite End -->

                    {% block content %}{% endblock %}
<div id="giga_147"></div>
<center><div id='b6c804f816'></div></center>
                </div>
            </div>
            <div id="footer">
                {% if is_main %}
                    <p>Добро пожаловать на <strong>развлекательный портал Хохот</strong>. У нас вы найдете:  <strong>классные картинки, прикольное видео, лучшие демотиваторы, картинки девушек, красивые открытки, хороший юмор</strong>.</p>
                    <p>Хохот - это всегда новые <strong onclick="$('#toWallDialog').dialog('open');">приколы онлайн</strong> на любой вкус и возраст! Ежедневно обрабатывается огромное количество материала и отбирается для Вас только лучшее и самое интересное в интернете. Присоединяйся к нам ,и мы подарим тебе море позитива.</p>
                {% endif %}
                <div style="text-align: center">
                    <!--LiveInternet counter--><script type="text/javascript"><!--
                    document.write("<a href='http://www.liveinternet.ru/click' "+
                    "target=_blank><img src='//counter.yadro.ru/hit?t26.1;r"+
                    escape(document.referrer)+((typeof(screen)=="undefined")?"":
                    ";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
                    screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
                    ";"+Math.random()+
                    "' alt='' title='LiveInternet: показано число посетителей за"+
                    " сегодня' "+
                    "border='0' width='88' height='15'><\/a>")
                    //--></script><!--/LiveInternet-->
                </div>
            </div>
        </div>
        <style>
            #sandbox{
                display: none;
            }
			#toWallDialog{
				width: 300px;
			}
			#toWallDialog .list-wrapper{
				border: 1px #ccc solid;
				padding: 4px;
			}
			#toWallDialog ul{
				height: 200px;
				overflow: auto;
				padding:0px;
				margin: 0px;
			}
			#toWallDialog li{
				list-style: none;
				overflow: hidden;
				margin-bottom: 4px;
				cursor: pointer;
			}
			#toWallDialog li img{
				margin-right: 10px;
			}
			#toWallDialog li.selected{
				background: #f1f1f1;
			}
			#toWallDialog #userMessage textarea{
				display: block;
				width: 98%;
				height: 30px;
			}
			#toWallDialog .buttons-panel{
				margin-bottom: 5px;
			}
			.to-wall-button{
				display: block;
				background: url("/static/images/2wall.png") no-repeat left top;
				width: 140px;
				height: 27px;
				text-indent: -99999px;
				position: relative;
				top: -6px;
			}
        </style>
        <div id="sandbox">
            <div id="toWallDialog">
				<div class="buttons-panel">
					<input type="text" name="filter" value="" style="width: 80%;" />
					<input type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Поиск" onClick="wallDialog.filter($('#toWallDialog input[name=filter]').val()); return false;" style="float: right;" />
				</div>
				Кому:
				<div class="list-wrapper">
					<ul>
					</ul>
				</div>
				<div id="userMessage">
					Сообщение: <br/>
					<textarea name="message"></textarea>
				</div>
            </div>
            <input type="button" onclick="$('#toWallDialog').dialog('open');" value="ToWall" />
        </div>
		<script type="text/javascript">

			var wallDialog = {
				selected_uid: null,
				image: null,
				container: $("#toWallDialog"),
				src_list: [],
				list: [],
				init: function(data){
					this.src_list = data;
					this.list = data;
					this.render();
				},
				filter: function(str){
					// --
					this.selected_uid = null;
					this.container.find("li.selected").removeClass("selected");
					// -- 
					this.list = new Array();
					for(var i=0; i<this.src_list.length; i++){
						var tmp = this.src_list[i].first_name+" "+this.src_list[i].last_name;
						if(!(tmp.toLowerCase().search(str.toLowerCase()) == -1)){
							this.list.push(this.src_list[i]);
						}
					}
					this.render();
				},
				open: function(image){
					this.image = image;
					this.container.dialog('open');
				},
				render: function(){
					this.container.find("ul").html("");
					for(var i=0; i<this.list.length; i++){
						this.container.find("ul").append("<li id='user-"+this.list[i].uid+"' onclick='wallDialog.select("+this.list[i].uid+"); return false;'><img src='"+this.list[i].photo+"' style='float: left;'>"+this.list[i].first_name+" "+this.list[i].last_name+"</li>");
					}
				},
				select: function(uid){
					this.selected_uid = uid;
					this.container.find("li.selected").removeClass("selected");
					this.container.find("#user-"+uid).addClass("selected");
				},
				submit: function(){
					var self = this;
					var image = this.image;
					VK.api('wall.getPhotoUploadServer', {}, function (data){
						if(data.response){
							$.post("/vk_upload.php", {url: data.response.upload_url, photo: image, link: window.location.href}, function(response){
								self.container.dialog("close");
								var request = {
									wall_id: self.selected_uid, 
									message: self.container.find("textarea").val()+"\nОтправлено из http://vkontakte.ru/app2023356", 
									server: response.api.server, 
									photo: response.api.photo, 
									hash: response.api.hash, 
									post_id: response.pid
								}
								VK.api('wall.savePost', request, function(data){
									VK.callMethod('saveWallPost', data.response.post_hash);
								});								
							});
						}
					});
				}
			}

			VK.api(
				'friends.get',
				{
				    fields: 'nickname, sex, bdate, photo, photo_big, rate, home_phone, mobile_phone, faculty_name, graduation',
				    name_case: 'nom'
				}, function(data) {
					wallDialog.init(data.response);
					$("#toWallDialog").dialog({
						autoOpen: false,
						title: "Отправить на стену",
						modal: true,
						width: 200,
						show: 'fade',
						hide: 'fade',
						buttons: {
							'Отмена': function(){
								$("#toWallDialog").dialog("close");
							},
							'Отправить': function(){
								wallDialog.submit();
							}
						}
					});
				}
			);
			
			$(".cut img").each(function(){
				var self = this;
				$(self).after("<a href='#' class='to-wall-button' imgurl='"+$(self).attr("src")+"' onclick='return false;'>Отправить на стену</a>");
			});
			
			$(".to-wall-button").bind('click', function(e){
				$("#toWallDialog").dialog('option', 'position', ['center', e.clientY-400]);
				wallDialog.open($(this).attr('imgurl'));
			});
			
			VK.callMethod("scrollWindow", 0, 0);
			
			VK.api("getVariable", {key:'1280'}, function(data){
				var uid = data.response;
				VK.api("isAppUser", {uid: uid}, function(data){
					if(data.response == "1"){
						// -- user install this application
						$.post("/vkontakte/add_user", {uid: uid});
					}
				});
				//$.post("/vkontakte/", {uid:data.response});
			});			
			
			// -- wrap emoticons with links toWall .emoticon
			
		</script>


<script type="text/javascript">
var MGCD = new Date();
var min_width = '250';
var min_height = '150';
var overlay_interval = '40';
var overlay_height = '55';
var mg_opacity = '0.8';
var mg_bgcolor = '#353535';

document.write('<scr'
+'ipt type="text/javascript"'
+' src="http://jsc.dt00.net/x/o/xoxot.com.ua.18227.js?t='
+MGCD.getYear()
+MGCD.getMonth()
+MGCD.getDay()
+MGCD.getHours()
+'" charset="utf-8"></scr'+'ipt>');
</script>

<script type="text/javascript">
var MGCD = new Date();
document.write('<scr'
+'ipt type="text/javascript"'
+' src="http://jsc.dt00.net/x/o/xoxot.com.ua.25860.js?t='
+MGCD.getYear()
+MGCD.getMonth()
+MGCD.getDay()
+MGCD.getHours()
+'" charset="utf-8"></scr'+'ipt>');
</script>

			<!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter14523412 = new Ya.Metrika({id:14523412, enableAll: true, ut:"noindex", webvisor:true}); } catch(e) {} }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/14523412?ut=noindex" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->

<script type='text/javascript' src='http://ad05f.ru/code/bshow.php?dimension=500x250&id=1459'></script>		

    </body>
</html>
